package com.chinasofti.collection;

import com.chinasofti.optional.Student;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Demo06 {
    public static void main(String[] args) {
        Collection<Student> list = new ArrayList<>();
        Student student1 = new Student("a",1);
        Student student2 = new Student("b",2);
        Student student3 = new Student("c",3);
        list.add(student1);
        list.add(student2);
        list.add(student3);
        for (Student s:list){
            System.out.println(s);
        }
        Iterator it = list.iterator();
        while(it.hasNext()){
            Student student = (Student) it.next();
            System.out.println(student);

        }

    }
}
